<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工作票识别结果</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
    <style type="text/css">
        a:link { color: black; }
        a:hover { color: red; }
        .noaccess{
            color: red!important;
        }
    </style>
</head>
<body>
<div class="mainBox">
    <div class="main-container">
        <div id="fenxi"></div>
        <br>
        <div id="master"></div>
        <br>
        <div id="workers"></div>
        <br>
        <span>查看识别结果图片: </span>
        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="pic" title="查看图片" id="pic" onclick="showI()"><i
                    class="layui-icon layui-icon-picture"></i></button>

        <div style="font-size: 10px;position: absolute;left: 20px;bottom: 20px">
            <span>*备注:</span>
            <span style="color: red">红色</span>
            <span>为未准入/未录入人员</span>
        </div>
    </div>
</div>

</body>
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    var textArr = ["工作负责人签名:","施工人员签名: "]
    function changeUser(str,num){
        if (str !== ""){
            let arr = str.split("、")
            let result = "<span>"+textArr[num]+"</span>"
            arr.forEach((item,idx) => {
                if (item.indexOf("*")!==-1){    //有*
                    item = item.replace("*","")
                    // result += "<a href='javascript:;' class='noaccess' onclick='saveOrUpdate(\'"+item+"\')'>"+item+"</a>"
                    result += '<a href="javascript:;" class=\'noaccess\' onclick="saveOrUpdate(\''+item+'\')">'+item+'</a>';
                }else {
                    // result += "<a href='javascript:;' onclick='saveOrUpdate(\'"+item+"\')'>"+item+"</a>"
                    result += '<a href="javascript:;" onclick="saveOrUpdate(\''+item+'\')">'+item+'</a>';
                }
                if (idx !== arr.length-1){
                    result+="、"
                }
            })
            return result
        }
    }

    layui.use(['upload', 'element', 'layer'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;
        let MODULE_PATH = "${ctxPath}/ocr/";

        let master = '${result.master!}'
        let workers = '${result.workers!}'
        $("#fenxi").html("识别分析结果: "+ '${result.result!}');
        // $("#master").html("工作负责人签名: "+ '${result.master!}');
        $("#master").html(changeUser(master,0));
        $("#workers").html(changeUser(workers,1));
        // $("#workers").html("施工人员签名: "+ '${result.workers!}');


        window.showI = function () {
            var url = '${result.url!}';
            $.ajax({
                url: MODULE_PATH+"getImage?url="+url,
                dataType:'json',
                type:'get',
                success:function(result){
                    var imgHtml = "<img src='"+result+"' onerror=\"javascript:this.src='${ctxPath}/static/resource/images/pic404.png'\" width='600px' height='500px'/>";
                    layer.open({
                        type: 1,
                        shadeClose: true,
                        scrollbar: false,
                        maxmin: true,
                        shade: 0.1,
                        title: "工作票图片",
                        content: imgHtml,
                        cancel: function () {
                        }
                    })
                }
            })
        }

        window.saveOrUpdate = function (name) {
            layer.open({
                type: 2,
                title: '人员信息',
                shade: 0.1,
                area: ['60%', '600px'],
                content: MODULE_PATH + 'view/saveOrUpdate' + '?name='+name
            });
        }
    })
</script>
</html>